package cn.alex.sso.client.demo.util;

import cn.dev33.satoken.sign.SaSignTemplate;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

import java.nio.charset.StandardCharsets;

/**
 * @author Alex
 * @date 2025/1/10 下午1:23
 */
public class LscUtil {
    private static final SaSignTemplate saSignTemplate = new SaSignTemplate();

    /**
     * 解密
     *
     * @param content 待解密内容
     */
    public static String decrypt(String content) {
        byte[] key = saSignTemplate.getSecretKey().getBytes(StandardCharsets.UTF_8);
        byte[] aesKey = new byte[16];
        System.arraycopy(key, 0, aesKey, 0, 16);

        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, aesKey);

        return aes.decryptStr(content);
    }
}
